import random
import math


class Material(object):
    # 0:y=ax 1:y=ax^2 2:y=ax^3

    def __init__(self, level=1, name="养成材料"):
        self.level = level
        self.name = name
        self.fun_type = random.randint(0, 2)

    def use_material(self):
        from Main import user
        if self.fun_type == 0:
            value = random.uniform(1.05, math.log(self.level + 2.1, 2))*user.weight
            a = value/user.weight
            user.weight *= a
            print("y =", a, "x")
        elif self.fun_type == 1:
            value = random.uniform(1.1, math.log(self.level + 2.3, 2))*user.weight
            a = value/user.weight/user.weight
            user.weight = a * user.weight * user.weight
            print("y =", a, "x^2")
        elif self.fun_type == 2:
            value = random.uniform(1.1, math.log(self.level + 2.3, 2))*user.weight
            a = value/user.weight/user.weight/user.weight
            user.weight = a * user.weight * user.weight * user.weight
            print("y =", a, "x^3")

        print("使用增强后：", round(user.weight, 2), "\n")
